package ysq.xyg.base.extend.netty;

import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * @author taocongcong
 * @create 2019-03-12 16:29
 */
@Component
public class WebSocketApplicationRunner {
    /**
     * 使用线程开启netty服务
     * @author congcong tao
     * @date 2019/4/1 8:50
     */
    @PostConstruct
    public void initNetty() throws Exception {
        new WebSocketThread().start();
    }

    /**
     * 开启netty服务
     * @author congcong tao
     * @date 2019/4/1 8:50
     */
    private class WebSocketThread extends Thread {
        @Override
        public void run() {
            try {
                new WebSocketServer(9898).start();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}
